package com.ruoyi.accountant.dao;

import com.ruoyi.accountant.domain.Balance;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface BalanceDao extends TempDao<Balance, Long> {
    /***
     * 根据账户查询余额
     * @param ofAccount
     * @return
     */
    List<Balance> findAllByOfAccount(Long ofAccount);

    /***
     * 根据账户和货币查询余额
     * @param ofAccount
     * @param ofCurrency
     * @return
     */
    @Query("from Balance where ofAccount = ?1 and ofCurrency.cid = ?2")
    Balance findTop1ByOfAccountAndOfCurrency(Long ofAccount, Integer ofCurrency);
}
